<?php

class ModNivelAcceso{
	
	public $bd;
	public $resultado;

	
	public function __construct(){
		
		$this->bd = new Basedatos();
		
	}
		public function mostrar_mna(){
		
		$query = "CALL ConsultarModulosDeNivelAcceso()";
		$this->result = $this->bd->select($query);
		return $this->result;		
		
	}
		public function editar_na(){
		
		$query = "SELECT * FROM cargo";
		$this->result = $this->objDb->select($query);
		return $this->result;		
		
	}
		public function insertar_na(){
		
		$query = "CALL IngresarCargo('".$_POST["nombre"]."', '".$_POST["descr"]."')";
		$res = mysql_query($query);
		
	}
	public function ingreso_mna($var, $habi){
		$query ="CALL IngresarModuloNivelAcceso('".$var."','".$habi."')";
		$this->result = $this->bd->insert($query);

	}
	public function elimina_mna($var, $deshabi){
		$query ="CALL EliminarModuloNivelAcceso('".$deshabi."','".$var."')";
		$this->result = $this->bd->delete($query);
	}
	public function ingreso_una($var, $habi){
		$query ="CALL ModificarNivelAccesoDelUsuario('".$var."','".$habi."')";
		$this->result = $this->bd->insert($query);

	}
	public function elimina_una($rut){
		$query ="CALL EliminarNivelAccesoDelUsuario('".$rut."')";
		$this->result = $this->bd->delete($query);
	}
	public function existe_mna($idmodulo, $idna){
		
		$query = "CALL ExisteMNA('".$idna."','".$idmodulo."')";
		$this->result = $this->bd->select($query);
		$row=mysql_fetch_array($this->result);
			if ($row['contador'] > 0){
				$res = true;
			}else{
				$res = false;
			}
			return $res;

		}
	public function existe_una($rut, $idna){
		
		$query = "CALL Existe_UNA('".$rut."','".$idna."')";
		$this->result = $this->bd->select($query);
		$row=mysql_fetch_array($this->result);
			if ($row['contador'] > 0){
				$res = true;
			}else{
				$res = false;
			}
			return $res;

		}
		
	}

?>